const processor = {
  configClicked(currentGame, index, value) {
    let _current = _.assign({},currentGame);
    const cgCopy = _current.config
    if (!cgCopy.options[index].muti) {
      cgCopy.options[index].selected = [value]
    } else {
      if (cgCopy.options[index].selected.some(sel => sel === value)) {
        _.remove(cgCopy.options[index].selected, sel => sel === value)
      } else {
        cgCopy.options[index].selected.push(value)
      }
    }

    // ------------- 特殊处理
    if (cgCopy.name === '长沙麻将') {
      const zhaniaoTypeConf = cgCopy.options.find(conf => conf.key === 'zhamaType')
      const zhaniaoConf = cgCopy.options.find(conf => conf.name === '扎鸟数')
      // 1 是中鸟加分
      if (zhaniaoTypeConf.selected[0] === 1) {
        if (_.maxBy(zhaniaoConf.choice, cho => cho.value).value === 3) {
          console.log('中鸟分');
          zhaniaoConf.selected[0] = zhaniaoConf.selected[0] * 2
          zhaniaoConf.choice = [{ label: '2个', value: 2 }, { label: '4个', value: 4 }, { label: '6个', value: 6 }]
        }
      } else {
        if (_.maxBy(zhaniaoConf.choice, cho => cho.value).value === 6) {
          console.log('gai中鸟被');
          zhaniaoConf.selected[0] = zhaniaoConf.selected[0] / 2
          zhaniaoConf.choice = [{ label: '1个', value: 1 }, { label: '2个', value: 2 }, { label: '3个', value: 3 }]
        }
      }
    }

    // ------------- 特殊处理
    if (cgCopy.name === '惠州麻将') {
      const maModeConf = cgCopy.options.find(conf => conf.key === 'maMode')
      let selected = maModeConf.selected;

      console.error(selected);

      // 找到跟至对对碰
      if(selected.indexOf("magenduipeng") !== -1) {
         if(selected.indexOf("magengdifen") == -1) {
          selected.push("magengdifen")
        }
      }

    }

    // 选择六人时关闭
    if (cgCopy.name === '点子牛') {
      // const maxPlayerCountConf = cgCopy.options.find(conf => conf.key === 'maxPlayerCount')
      const maxBetPointConf = cgCopy.options.find(conf => conf.key === 'maxBetPoint')

      // if (maxPlayerCountConf.selected[0] === 6) {
      //   maxBetPointConf.selected[0] = 5
      //   maxBetPointConf._visible = false
      // } else {
      //   maxBetPointConf._visible = true
      // }
        maxBetPointConf._visible = true
      
    }


    if (cgCopy.name === '欢乐金花') {
      // const maxPlayerCountConf = cgCopy.options.find(conf => conf.key === 'maxPlayerCount')

      // if (maxPlayerCountConf.selected[0] === 6) {
      //   maxBetPointConf.selected[0] = 5
      //   maxBetPointConf._visible = false
      // } else {
      //   maxBetPointConf._visible = true
      // }
      
    }
    return _current
  }
}

export default processor